package org.corey.share.business;

import org.corey.share.db.entity.PhotoAlbum;
import org.corey.share.db.service.AlbumService;
import org.corey.share.db.service.AlbumServiceImpl;
import org.corey.share.misc.PageData;

import com.opensymphony.xwork2.ActionSupport;

public class AlbumAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private AlbumService albumService = new AlbumServiceImpl();
	private PhotoAlbum album;
	private int pageIndex;
	private int pageSize;
	private PageData<PhotoAlbum> pageData;
	private Long deletedAlbumId;
	private boolean optResult;

	public int getPageIndex() {
		return pageIndex;
	}

	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public PageData<PhotoAlbum> getPageData() {
		return pageData;
	}

	public void setPageData(PageData<PhotoAlbum> pageData) {
		this.pageData = pageData;
	}

	public boolean getOptResult() {
		return optResult;
	}

	public void setOptResult(boolean optResult) {
		this.optResult = optResult;
	}

	/********************** 业务接口 *****************************/
	public String add() {
		optResult = albumService.saveAlbum(album);
		return SUCCESS;
	}

	public String display() {
		pageData = albumService.getPhotoAlbum(pageIndex, pageSize);
		return SUCCESS;
	}

	public String delete() {
		if (deletedAlbumId != null) {
			optResult = albumService.deleteAlbum(deletedAlbumId);
		}
		return SUCCESS;
	}

	public String update() {
		optResult = albumService.updateAlbum(album);
		return SUCCESS;
	}
}
